/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2023 —10 —16
 * Time: 21:18
 */
public class test_10_16 {
    public static void move(char pos1 , char pos2){
        System.out.print(pos1 + "=>" + pos2 + "  ");
    }

    /**
     *
     * @param n 盘子的数量
     * @param pos1  起始位置
     * @param pos2  中转位置
     * @param pos3  目的地位置
     */
    public static void hanio(int n , char pos1, char pos2 , char pos3){
        if(n == 1){
            move(pos1,pos3);
            return;
        }
        hanio(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanio(n-1,pos2,pos1,pos3);

    }

    public static void main(String[] args) {
        hanio(4,'A','B','C');
        System.out.println();
    }
}
